package Array;

/**
 * ClassName: Student
 * Package: Array
 *
 * @Author 马学兴
 * @Create 2023/12/1 14:03
 * @Version 1.0
 * Description:
 */
public class Student implements Comparable<Student>{
    private String name;
    private int score;
    public Student(String name,int score){
        this.name=name;
        this.score=score;
    }
    @Override
    public int compareTo(Student another) {
      /* if (this.score< another.score)
           return -1;
       else if (this.score==another.score)
           return 0;
       return 1;*/
        return this.score - another.score;
    }
    @Override
    public boolean equals(Object student){//自定义equal方法
        if (this==student)
            return true;
        if (student==null)
            return false;
        if (this.getClass()!=student.getClass())
            return false;
        Student another= (Student) student;
        return this.name.equals(another.name);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", score=" + score +
                '}';
    }

    public static void main(String[] args) {
        Array<Student> arr=new Array<Student>();
        arr.addLast(new Student("a",100));
        arr.addLast(new Student("a",100));
        arr.addLast(new Student("a",100));
        System.out.println(arr);
    }
}
